//
// Created by sjjmw on 3/24/2022.
//

//应该使用dfs

#include "iostream"
#include "vector"
#include "list"
#include "algorithm"
#include "string"
#include "unordered_map"
#include "cmath"
#include<iomanip>
#include "string"
#include "map"
#include "list"
struct Sol{
    std::vector<std::string> map;
    std::vector<std::vector<int>> tag;
    int w;
    bool is_sea(int x,int y){
        if(x<0||x>=w||y<0||y>=w){
            return false;
        }
        return map[y][x]=='.';
    }
    void dfs(int x,int y,int&cnt_of_side,int &cnt_of_all){
        if(x<0||x>=w||y<0||y>=w){
            return;
        }
        if(tag[y][x]!=0||map[y][x]=='.'){
            return;
        }
        if(!is_sea(x+1,y)&&
            !is_sea(x-1,y)&&
            !is_sea(x,y+1)&&
            !is_sea(x,y-1)){
            //都不是海
            tag[y][x]=1;
        }else{
            tag[y][x]=2;
            cnt_of_side++;
//            map[y][x]=' ';
        }
        cnt_of_all++;
        dfs(x+1,y  ,cnt_of_side,cnt_of_all);
        dfs(x+1,y+1,cnt_of_side,cnt_of_all);
        dfs(x+1,y-1,cnt_of_side,cnt_of_all);
        dfs(x-1,y  ,cnt_of_side,cnt_of_all);
        dfs(x-1,y-1,cnt_of_side,cnt_of_all);
        dfs(x-1,y+1,cnt_of_side,cnt_of_all);
        dfs(x,y-1  ,cnt_of_side,cnt_of_all);
        dfs(x,y+1  ,cnt_of_side,cnt_of_all);
    }
    void dfs2(int x,int y){

    }
    void handle(
            //n张，k种
            int n
            ){
        w=n;
        map.reserve(w);
        tag.reserve(w);
        std::vector<int> tag_line(w);
//        std::vector<int> line(w);
        std::string line;
        std::getline(std::cin,line);
        for (int i = 0; i < w; ++i) {
//            for (int j = 0; j < w; ++j) {
//                std::cin>>line[j];
//            }
            std::getline(std::cin,line);
            map.push_back(line);
            tag.push_back(tag_line);
        }
        int dycnt=0;

        for (int i = 0; i < w; ++i) {
            for (int j = 0; j < w; ++j) {
                if(tag[i][j]==0&&map[i][j]=='#'){
                    int cnt_of_side=0,cnt_of_all=0;
                    dfs(j,i,cnt_of_side,cnt_of_all);
                    if(cnt_of_side==cnt_of_all){
                        dycnt++;
                    }
                }
            }
        }
//        int dycnt2=0;
//        for (int i = 0; i < w; ++i) {
//            for (int j = 0; j < w; ++j) {
//                if(tag[i][j]==1&&map[i][j]=='#'){
//                    dfs2(j,i);
//                    dycnt2++;
//                }
//            }
//        }
//        std::cout<<std::endl;
//        for(auto line:map){
//            std::cout
//                <<line<<std::endl;
//        }
        printf("%d\n",dycnt);
        ;
    }
};
int main(){
    int a,b,c;
//    float a,b,c,d;
    int e;
    while(std::cin>>a){
        Sol().handle(a);

//        Sol().handle(a,b);
    }

    return 0;
}